package dice.sinanya;

import com.itextpdf.text.DocumentException;
import dice.sinanya.tools.makedata.SavePdf;
import org.nlpcn.commons.lang.util.StringUtil;

import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;

import static dice.sinanya.system.MessagesHelp.helpMap;

public class MakePdf {
    public static void main(String[] args) throws IOException, DocumentException {
        SavePdf savePdf = new SavePdf();
        LinkedHashMap<String, String> text = new LinkedHashMap<>();
        for (Map.Entry<String, String> map : helpMap.entrySet()) {
            ArrayList<String> info = new ArrayList<>();
            if (map.getKey().contains("update") && map.getKey().contains("yes")) {
                continue;
            }
            String[] list = map.getValue().split("\n");
            for (int i = 0; i < list.length; i++) {
                if (i != 0) {
//                    if (!list[i].contains(":") && !list[i].contains("：")) {
                    info.add("        " + list[i]);
//                    } else {
//                        info.add(list[i]);
//                    }
                }
            }
            text.put(map.getValue().split("\n")[0], StringUtil.joiner(info, "\n").replace("\\t", "   ").replace("\t", "   "));
        }
        savePdf.save("塔骰用户手册.pdf", text);
    }
}
